//
//  LoginViewModel.m
//  ForYourBeauty
//
//  Created by Kelly xu on 2019/6/3.
//  Copyright © 2019 changrenTech. All rights reserved.
//

#import "LoginViewModel.h"

@implementation LoginViewModel
-(void)loginWithMob:(NSString*)mob pwd:(NSString*)pwd cmp:(void(^)())cmp{
    [[HttpClient shareClient]postWithUrl:LOGIN params:@{@"userMobile":mob,@"userPassword":pwd,@"userMac":@"50:64:2b:9e:f7:f1"} suc:^(id results) {
        [[LoginTools sharedTools] saveUserInfo:[results mj_JSONObject]];
        cmp();
    } fail:^(NSString *error, NSInteger status) {
        Toast(error);
    }];
}
-(void)registerWithMob:(NSString*)mob checkCode:(NSString*)checkCode pwd:(NSString*)pwd cmp:(void(^)())cmp{
    [[HttpClient shareClient]postWithUrl:REGISTER params:@{@"userMobile":mob,@"userPassword":pwd,@"verificationCode":checkCode,@"userMac":@"50:64:2b:9e:f7:f1"} suc:^(id results) {
        cmp();
    } fail:^(NSString *error, NSInteger status) {
        Toast(error);
    }];
}
-(void)fetchCheckCode:(NSString*)mob cmp:(void(^)())cmp{
    [[HttpClient shareClient]postWithUrl:SEND_SMS params:@{@"userMobile":mob,@"sendType":@"1"} suc:^(id results) {
        cmp();
    } fail:^(NSString *error, NSInteger status) {
        Toast(error);
    }];
}
-(void)fogotPwdWithMob:(NSString*)mob checkCode:(NSString*)checkCode pwd:(NSString*)pwd cmp:(void(^)())cmp{
    [[HttpClient shareClient]postWithUrl:FOGOT_PWD params:@{@"userMobile":mob,@"userPassword":pwd,@"verificationCode":checkCode,@"userMac":@"50:64:2b:9e:f7:f1"} suc:^(id results) {
        cmp();
    } fail:^(NSString *error, NSInteger status) {
        Toast(error);
    }];
}
-(void)editPwdWithMob:(NSString*)mob checkCode:(NSString*)checkCode pwd:(NSString*)pwd cmp:(void(^)())cmp{
    [[HttpClient shareClient]postWithUrl:EDIT_PWD params:@{@"userMobile":mob,@"userPassword":pwd,@"verificationCode":checkCode,@"userMac":@"50:64:2b:9e:f7:f1"} suc:^(id results) {
        cmp();
    } fail:^(NSString *error, NSInteger status) {
        Toast(error);
    }];
}
@end
